#!/bin/bash
node="$1"
metaID=$2
src_meta="./meta/build/orcafs-meta"
passStr="p@ssword"
#passStr="Orcadt@123"

if (($# != 2));then
	echo "Usage: sh $0 <96.100> <metaID>"
	exit 1
fi

if [ ! -e ${src_meta} ];then
    echo "Usage: sh $0 <96.100> <metaID>"
    echo "file(${src_meta}) is not exist"; exit
fi

dest_meta="/opt/orcafs/sbin/orcafs-meta"

function update_meta()
{
    echo -----copyTo--------"${node}"----"${src_meta}"-------
    eval sshpass -p ${passStr} ssh root@192.168."${node}" 'systemctl stop orcafs-meta@*'
    sshpass -p ${passStr} scp ${src_meta} root@192.168."${node}":${dest_meta}

    echo -----restart-------"${node}"----"orcafs-meta@${metaID}"-------
    eval sshpass -p ${passStr} ssh root@192.168."${node}" 'systemctl start orcafs-meta@${metaID}'
    eval sshpass -p ${passStr} ssh root@192.168."${node}" 'systemctl status orcafs-meta@${metaID} | grep Active'
}

update_meta
